package com.example.exception;

import com.example.pojo.Result;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public Result exceptionHandler(Exception e) {
        return Result.error(e.getMessage());
    }

    @ExceptionHandler
    public Result accessDeniedHandler(AccessDeniedException e) {
        return Result.error(403, "权限不足");
    }

}
